package com.engine4cloud.tdf.supervision.controller.inner;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.supervision.dto.create.RcglOccasionSignCreateDTO;
import com.engine4cloud.tdf.supervision.dto.query.RcglOccasionSignQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglOccasionSignResultDTO;
import com.engine4cloud.tdf.supervision.service.RcglOccasionSignService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 现场签到管理（单独的功能与教育学习模块没有关系）
 *
 * @author wenjie
 * @date 2024-07-24 17:23:37
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/occasion/sign")
@Tag(description = "lOccasionSign", name = "日常管理-现场签到-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RcglOccasionSignInnerController {

    private final RcglOccasionSignService occasionSignService;

    /**
     * 分页查询
     *
     * @param dto 矫正对象现场签到
     * @return R<PageInfo < RcglOccasionSignResultDTO>>
     */
    @Inner
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<RcglOccasionSignResultDTO>> pageList(@Valid @RequestBody RcglOccasionSignQueryDTO dto) {
        return R.ok(occasionSignService.pageList(dto));
    }

    /**
     * 通过id查询矫正对象现场签到
     *
     * @param id id
     * @return R
     */
    @Inner
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<RcglOccasionSignResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(occasionSignService.getById(id));
    }

    /**
     * 新增矫正对象现场签到
     *
     * @param dto 矫正对象现场签到
     * @return R
     */
    @Inner
    @Operation(summary = "新增矫正对象现场签到", description = "新增矫正对象现场签到")
    @SysLog("新增矫正对象现场签到")
    @PostMapping
    public R<Boolean> create(@Valid @RequestBody RcglOccasionSignCreateDTO dto) {
        return R.ok(occasionSignService.create(dto));
    }
}